/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerz.component.panel;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import towerz.game.entity.tower.Tower;
import towerz.system.BitmapFont;
import towerz.system.StringManager;

/**
 *
 * @author LegACy
 */
public class TowerSell extends Panel {
	public TowerSell(Image image, int x, int y) {
		//Suoer
		super(image, x, y);
	}

	public void show(Tower tower) {
		//Super
		super.show();

		//Show tower
		m_Tower = tower;
		
		//Create string
		String DamageStr = StringManager.instance().getString("damage") + " " + m_Tower.getData().getBullet().getDamage() + " + " + m_Tower.getHut().getData().getBonusDmg();

		m_StringImg = new Image[4];
		m_StringImg[0] = m_Tower.getData().getNameString();
		m_StringImg[1] = BitmapFont.getFont(0).renderTransparentText(DamageStr, 0x00000000);
		m_StringImg[2] = BitmapFont.getFont(0).renderTransparentText(StringManager.instance().getString("fire-to-sell"), 0x00000000);
		m_StringImg[3] = BitmapFont.getFont(0).renderTransparentText(m_Tower.getData().getSell() + " " + StringManager.instance().getString("culture"), 0x00000000);
	}

	public void hide() {
		//Super
		super.hide();

		//No tower
		m_Tower		= null;
		m_StringImg = null;
	}

	public void draw(Graphics g) {
		//Skip if not visible or no tower
		if (g == null) return;
		if (m_Tower == null || m_StringImg == null)	return;
		super.draw(g);

		//Draw data
		if (m_StringImg[0] != null) g.drawImage(m_StringImg[0], m_X + 8, m_Y + 8, Graphics.LEFT | Graphics.TOP);
		if (m_StringImg[1] != null) g.drawImage(m_StringImg[1], m_X + 8, m_Y + 25, Graphics.LEFT | Graphics.TOP);

		if (m_StringImg[2] != null) g.drawImage(m_StringImg[2], m_X + m_Background.getWidth()/2, m_Y + m_Background.getHeight() - 28, Graphics.HCENTER | Graphics.TOP);
		if (m_StringImg[3] != null) g.drawImage(m_StringImg[3], m_X + m_Background.getWidth()/2, m_Y + m_Background.getHeight() - 16, Graphics.HCENTER | Graphics.TOP);
		//g.drawImage(BitmapFont.getFont(0).renderTransparentText(m_Tower.getData().getSell() + " culture", 0x00000000), m_X + 8, m_Y + m_Background.getHeight() - 16, Graphics.TOP | Graphics.LEFT);
	}
	
	//Data
	protected Tower m_Tower;

	protected Image[] m_StringImg;
}
